package com.mex_native;

import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.widget.Toast;

import com.facebook.react.ReactActivity;
import com.mex_native.rfid.RFIDInterface;
import com.rscja.deviceapi.RFIDWithUHF;

public class MainActivity extends ReactActivity {

  private static MainActivity mainActivity;

  public RFIDInterface rfidInterface;

  public static MainActivity getInstances(){
    return mainActivity;
  }


  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mainActivity = this;
  }

  /**
   * Returns the name of the main component registered from JavaScript. This is used to schedule
   * rendering of the component.
   */
  @Override
  protected String getMainComponentName() {
    return "mex_native";
  }



  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.i("=====onKeydown", "" +keyCode);

    if (keyCode == 139 ||keyCode == 280 ||keyCode == 293) {

      if (event.getRepeatCount() == 0) {
        if (rfidInterface != null){
          rfidInterface.readTag();
        }

      }
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }









}
